@echo off
@REM 参数
set user=zhangyu
set port=22
set host=172.21.227.206
set rootDir=/home/zhangyu/Program/ohostest
set exeSrcDir=%rootDir%/code/out/sdk/mingw_x86_64/common/samples
set exeDstDir=D:\WorkDir\temp\previewer
set runLog=D:\WorkDir\temp\run.log

@REM 命令集
set initCode=repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
set syncCode=repo sync -c
set pulllfs=repo forall -c 'git lfs pull'
set prebuiltCode=bash build/prebuilts_download.sh
set buildCode=./build.sh --product-name ohos-sdk --gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true --gn-args enable_glfw_window=true --build-target ace_for_windows

ssh -p %port% %user%@%host% "rm -rf %rootDir%" > %runLog%
ssh -p %port% %user%@%host% "mkdir -p %rootDir%/code" >> %runLog%
ssh -p %port% %user%@%host% "cd %rootDir%/code; %initCode%" >> %runLog%
ssh -p %port% %user%@%host% "cd %rootDir%/code; %syncCode%" >> %runLog%
ssh -p %port% %user%@%host% "cd %rootDir%/code; %pulllfs%" >> %runLog%
ssh -p %port% %user%@%host% "cd %rootDir%/code; %prebuiltCode%" >> %runLog%
ssh -p %port% %user%@%host% "cd %rootDir%/code; %buildCode%" >> %runLog%

@REM 删除本地存放目录
if exist %exeDstDir% (
    rmdir /q/s %exeDstDir%
)

@REM 下载相关文件
set ftpFile=sftp.txt
>%ftpFile% (
    echo get -r %exeSrcDir% %exeDstDir%
    echo bye
)
sftp -b %ftpFile% %user%@%host%
del %ftpFile%

@REM 执行预览测试
